{template 'header'}
<div id="js-goods-seller" ng-controller="goodsSellerCtrl" ng-cloak>
	<ul class="we7-page-tab">
		<li class="active"><a href="#">应用模块</a></li>
		<!-- <li><a href="#">公众号个数</a></li> -->
		<!-- <li><a href="#">小程序个数</a></li> -->
	</ul>
	<form action="" class="form-inline clearfix we7-margin-bottom" method="post">
		<input type="hidden" class="online" value="{$status}">
		<div class="input-group form-group" style="width: 400px;">
			<input type="text" name="keyword" value="{$keyword}" class="form-control" placeholder="搜索">
			<span class="input-group-btn"><button class="btn btn-default"><i class="fa fa-search"></i></button></span>
		</div>
	</form>
	<button class="pull-right btn btn-primary" ng-click="showModule()">添加</button>
	<div class="btn-group we7-btn-group we7-margin-bottom">
		<a href="{php echo $this->createWebUrl('goodsSeller', array('direct' => 1))}" class="btn" ng-class="{'active': status}">上架应用</a>
		<a href="{php echo $this->createWebUrl('goodsSeller', array('online' => STATUS_OFF, 'direct' => 1))}" class="btn" ng-class="{'active': !status}">未上架应用</a>
	</div>
	<table class="table we7-table vertical-middle">
		<col width="105px"/>
		<col width="500px"/>
		<col />
		<col />
		<tr>
			<th colspan="2">应用信息</th>
			<th>单价</th>
			<th class="text-right">操作</th>
		</tr>
		{if !empty($goods_list)}
		{loop $goods_list $good}
		<tr>
			<td><img src="{$good['module_info']['logo']}" alt="" width="60" height="60"/></td>
			<td>
				<div class="we7-margin-bottom-sm">{$good['title']}</div>
				<div class="color-gray text-over" style="width:500px">{$good['description']}</div>
			</td>
			<td>{$good['price']}元/{if $good['unit'] == 'month'}月{else}月{/if}</td>
			<td ng-if="!status">
				<div class="link-group">
					<a href="{php echo $this->createWebUrl('goodspost', array('id' => $good['id'], 'direct' => 1))}">编辑</a>
					<a href="{php echo $this->createWebUrl('goodsseller', array('operate' => 'changestatus', 'id' => $good['id'], 'direct' => 1))}">上架</a>
					<a href="{php echo $this->createWebUrl('goodsseller', array('operate' => 'delete', 'id' => $good['id'], 'direct' => 1))}" class="del">删除</a>
				</div>
			</td>
			<td ng-if="status">
				<div class="link-group">
					<a href="{php echo $this->createWebUrl('goodspost', array('id' => $good['id'], 'direct' => 1))}">编辑</a>
					<a href="{php echo $this->createWebUrl('goodsseller', array('operate' => 'changestatus', 'id' => $good['id'], 'direct' => 1))}">下架</a>
				</div>
			</td>
		</tr>
		{/loop}
		{else}
		<tr>
			<td colspan="4" class="text-center">暂无数据</td>
		</tr>
		{/if}
	</table>
	<div class="pull-right">
		{$pager}
	</div>
	<div class="uploader-modal modal fade module" id="add_module"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog  modal-dialog modal-lg we7-modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<h4 class="modal-title">模块(点击添加)</h4>
				</div>
				<div class="modal-body material-content clearfix">
					<div class="material-head">
						<div class="form-horizontal clearfix">
							<div class="input-group pull-left col-sm-4">
								<input type="search" ng-model='keyword' class="form-control" placeholder="搜索关键字"/>
								<span class="input-group-btn"><button type="button" class="btn btn-default"><i class="wi wi-search"></i></button></span>
							</div>
						</div>
					</div>
					<div class="material-body">
						<div class="row">
							<div class="col-sm-2 select-module" ng-repeat="module in moduleList | filter:keyword">
								<div class="item">
									<img ng-src="{{module.logo}}" class="icon" ng-click="selectModule(module, $event)">
									<div class="name text-center">{{module.title}}</div>
									<div class="mask">
										<span class="wi wi-right"></span>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" ng-click="editPrice()">编辑价格</button>
					<button type="button" class="btn btn-primary" ng-click="toOffline()">添加到未上架</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	angular.module('storeApp').value('config', {
		'status' : {php echo $status},
		'goodsList': {php echo !empty($goods_list) ? json_encode($goods_list) : 'null'},
	'moduleList': {php echo !empty($module_list) ? json_encode($module_list) : 'null'},
	'token': {php echo json_encode($_W['token'])},
	'links': {
		'changestatus': "{php echo $this->createWebUrl('goodsSeller', array('operate' => 'changestatus', 'direct' => 1))}",
				'add': "{php echo $this->createWebUrl('goodsPost', array('operate' => 'add', 'direct' => 1))}",
				'offline': "{php echo $this->createWebUrl('goodsSeller', array('online' => '0', 'direct' => 1))}",
				'post': "{php echo $this->createWebUrl('goodsPost', array('direct' => 1))}",
	}
	});
	angular.bootstrap($('#js-goods-seller'), ['storeApp']);
</script>
{template 'common/footer'}